package ao

import (
	"context"
	pb "gitee.com/micro-services/protocol/hotel/server"
	"micro.hotel.server/impl"
)

type Hotel struct{}

func (h *Hotel) CreateHotel(ctx context.Context, r *pb.CreateHotelReq, w *pb.CreateHotelRsp) error {
	rsp, err := impl.CreateHotel(ctx, r)
	if err != nil {
		return err
	}

	w.Msg = rsp.Msg
	w.RetCode = rsp.RetCode
	return nil
}
func (h *Hotel) DeleteHotel(ctx context.Context, r *pb.DeleteHotelReq, w *pb.DeleteHotelRsp) error {
	rsp, err := impl.DeleteHotel(ctx, r)
	if err != nil {
		return err
	}

	w.Msg = rsp.Msg
	w.RetCode = rsp.RetCode
	return nil
}

func (h *Hotel) UpdateHotel(ctx context.Context, r *pb.UpdateHotelReq, w *pb.UpdateHotelRsp) error {
	rsp, err := impl.UpdateHotel(ctx, r)
	if err != nil {
		return err
	}

	w.Msg = rsp.Msg
	w.RetCode = rsp.RetCode
	return nil
}

func (h *Hotel) BatchHotelInfo(ctx context.Context, r *pb.BatchHotelInfoReq, w *pb.BatchHotelInfoRsp) error {

	info, err := impl.BatchHotelInfo(ctx, r)
	if err != nil {
		return err
	}

	w.HotelInfo = info
	return nil
}

func (h *Hotel) SearchHotel(ctx context.Context, r *pb.SearchHotelReq, w *pb.SearchHotelRsp) error {

	infos, count, err := impl.SearchHotel(ctx, r)
	if err != nil {
		return err
	}

	w.HotelInfo = infos
	w.Count = count
	return nil
}

func (h *Hotel) Recommend(ctx context.Context, r *pb.RecommendReq, w *pb.RecommendRsp) error {

	infos, count, err := impl.Recommend(ctx, r)
	if err != nil {
		return err
	}

	w.HotelInfo = infos
	w.Count = count
	return nil
}
